var express = require('express');
var router = express.Router();
const { uploadFiles } = require('../utils/handleFiles.js');

router.post('/uploadImages', function(req, res, next){
    const uploadResult = uploadFiles({
        path: './public/temp',//设置上传成功后的蹄片存储路径
        key: 'file',
        size: 8000
    });
    uploadResult(req, res, error => {
        if(error){
             console.log('图片上传失败', error);
        }else {
            console.log('图片上传成功', req.files);
            res.send({
                code: 1,
                message:'图片上传成功',
                result: './temp/' + req.files[0].filename,
            })
        }
    })
});

module.exports = router;